package com.hundsun.yr.universal.p2p.utils;

import android.text.TextUtils;

import com.android.volley.NetworkResponse;
import com.android.volley.VolleyError;




/**
 * @Title: VolleyErrorMessage.java 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @date 2015-11-11 上午9:17:50 
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com 
 * @replace author:
 * @replace date:
 * @version V1.0   
 */
public class VolleyErrorMessage {

	/**
	 * 获取返回错误message
	 * @param error
	 * @return
	 */
	public static String errorMessage(VolleyError error){
		NetworkResponse response = error.networkResponse;
		String errormessage=HTTP_0;
		if (response != null) {
			switch (response.statusCode) {
			case 404:
				errormessage= HTTP_404;
			case 500:
				errormessage= HTTP_500;
				break;
			case 503:
				errormessage= HTTP_503;
				break;
			case 900:
				errormessage= HTTP_900;
				break;
			case 901:
				errormessage= HTTP_901;
				break;
			case 902:
				errormessage= HTTP_902;
				break;
			case 903:
				errormessage= HTTP_903;
				break;
			case 400:
				errormessage= "参数错误";
				break;
			default:
				if(TextUtils.isEmpty(error.getMessage())){
					errormessage= HTTP_UNKONW;
				}else{
					errormessage=error.getMessage();
				}
				break;
			}
		}else{
			errormessage=HTTP_UNINTENET;
		}
		
		return errormessage;
		
	}

	// 服务器端返回的状态提示
	private static final String HTTP_0 = "其他错误";
	private static final String HTTP_404 = "404错误,请求链接无效";
	private static final String HTTP_500 = "网络500错误,服务器端程序出错";
	private static final String HTTP_503 = "网络503错误,服务器出错";
	private static final String HTTP_900 = "网络传输协议出错";
	private static final String HTTP_901 = "连接超时";
	private static final String HTTP_902 = "网络中断";
	private static final String HTTP_903 = "网络数据流传输出错";
	private static final String HTTP_UNKONW = "未知的错误";
	private static final String HTTP_UNINTENET = "网络连接异常!\n请在网络连接后重试！~";

}
